<template>
  <el-table :data="tableData" style="width: 100%" height="725px">
    <el-table-column prop="projectName" label="项目名" width="180"></el-table-column>
    <el-table-column prop="price" label="报价" width="180"></el-table-column>
    <el-table-column prop="timeLimit" label="工期"></el-table-column>
    <el-table-column prop="states" label="状态"></el-table-column>
    <el-table-column v-if="this.hh" label="操作">
      <template v-if="this.hh" slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">请求支付项目费用</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    data() {
      return {
        tableData: [
          {
            hh:'true',
            id:'',
            pid:'',
            price:'',
            projectName:'',
            timeLimit:'',
            projectDoc:'',
            states:''
          }
        ]
      }
    },
    mounted: function(){
      var user= JSON.parse(window.sessionStorage.getItem("user"));
      var ff = this.$route.query.mallCode  //输入内容
      axios.post('/workroom/lookOrder',{
        wid : ff,
        id:ff
      }).then((response) => {
        console.log(ff)
        if( response.data != null){
          this.$notify({
            title: '成功',
            message: '成功',
            type: 'success',
            duration:2000
          });
          var e=response.data
          var data=[];
          var pp=0
          for(var c=0;c<e.length;c++) {
            var ee = e[c];
            if(ee.states==4||ee.states==5) {

              var obj = {}
              obj.id = ee.id
              obj.pid = ee.pid
              obj.price = ee.price
              var nnn = ee.states
              if (nnn == 4) {
                obj.states = "平台未付款"
              } else if (nnn == 5) {
                obj.states = "平台付款"
                this.hh=false
              } else {
                obj.states = "平台付款"
              }
              obj.projectName = ee.projectName
              var ccc = ee.timeLimit
              var ggg = ccc.split("T")
              obj.timeLimit = ggg[0]
              obj.projectDoc = ee.projectDoc
              data[pp] = obj
              pp++}

            }
          this. tableData=data
        }

        else{
          this.$notify({
            title: '失败',
            message: '错误',
            type: 'warning',
            duration:2000
          });
        }
      })

    },
    methods: {
      handleEdit(index, row) {

        // this.fid = this.$route.query.
        // this.tid = this.$route.query.tid
        // this.fname = this.$route.query.name
        var user= JSON.parse(window.sessionStorage.getItem("user"));

        var ee=user.id
        // var ff=row.pid
        this.$router.push({
          path: '/SendMassage',
          query: {
            tid:1,
            fid:26,
            name:"zzzzz"
          }
        })

      },
      handleDelete(index, row) {
        console.log(index, row);
        var ff=row.id
        console.log(ff)
        axios.post('/workroom/deleteProjectApply',{
          id : ff,
          idd  : ff
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });
            location.reload()
          }
          else{
            this.$notify({
              title: '失败',
              message: '错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      }

    }

  }
</script>



<style scoped>

</style>
